package com.baiyun.stock.service.jobhandler;


import com.baiyun.stock.service.StockTimerTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class StockJob {
    private static Logger logger = LoggerFactory.getLogger(StockJob.class);

    @Autowired
    private StockTimerTaskService stockTimerTaskService;

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("testJobHandler") //自定义任务名称
    public void demoJobHandler() throws Exception {
        System.out.println("执行任务中，当前时间为："+new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
    }

    /**
     * 定时采集A股大盘数据
     * @throws Exception
     */
    @XxlJob("getStockDataJobHandler") //自定义任务名称
    public void getStockDataJobHandler() throws Exception {
        stockTimerTaskService.getInnerMarketInfo();
    }
}
